<?php




/**
* Lists entities in images
*/

# When a user will cancel add/edit forms, we will try to come back here
url::remember();

# Begin the paginator along with: images
# Parameter: GET[], and per page
$pagination = new pagination('pg', GALLERY_FRONT_IMAGES_PER_PAGE);

$images = new images();

$search_images = $variable->remember_string('search_images');
$smarty->assign('search_images', $search_images);

$condition = new condition();

$condition->add('FULL', array(
	"e.subdomain_id={$subdomain_id}", # Bind the records
	"e.is_active='Y'", # Do not remove this
	"e.is_approved='Y'", # Optionally use this flag
	
	# See images with few impressions
	# During development phase only
	"e.impressions_counter>0"
));

# Compulsory conditions
$condition->add('AND', array(
	#'e.search_field' => 'Y', # Partial %contents%
));

# List out the entries
$entries = $images->list_popular_images( # Instead write: list_popular_images
	$condition,
	$from_index=$pagination->begining_entry(),
	$pagination->per_page()
);

# Pagination helper
$pagination->set_total($images->total_entries());
$smarty->assignByRef('pagination', $pagination);

# Assign to Smarty: Lists
$smarty->assignByRef('imagess', $entries);
#print_r($entries);
?>